package com.hdw.med.service;

import com.hdw.common.vo.PaginationVO;
import org.springframework.stereotype.Service;
import com.hdw.med.api.BaseErrlogService;
import com.hdw.med.mapper.BaseErrlogMapper;
import com.hdw.med.bean.model.BaseErrlog;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * baseErrlog服务实现类
 * Created by liujunlei on 2022/01/31.
 */
@Service
@Transactional
public class BaseErrlogServiceImpl implements BaseErrlogService{

    private static final Logger LOGGER = LoggerFactory.getLogger(BaseErrlogServiceImpl.class);

    @Autowired
    private BaseErrlogMapper baseErrlogMapper;

    @Override
    public int insert(BaseErrlog baseErrlog) {
        return baseErrlogMapper.insert(baseErrlog);
    }

    @Override
    public int insertSelective(BaseErrlog baseErrlog)  {
        return baseErrlogMapper.insertSelective(baseErrlog);
    }

    @Override
    public int deleteById(Long idErrlog)  {
        return baseErrlogMapper.deleteByPrimaryKey(idErrlog);
    }

    @Override
    public int updateByIdSelective(BaseErrlog baseErrlog)  {

        return baseErrlogMapper.updateByPrimaryKeySelective(baseErrlog);
    }

    @Override
    public int updateById(BaseErrlog baseErrlog)  {
        return baseErrlogMapper.updateByPrimaryKey(baseErrlog);
    }

    @Override
    public BaseErrlog getById(Long idErrlog)  {
        return baseErrlogMapper.selectByPrimaryKey(idErrlog);
    }

    @Override
    public List<BaseErrlog> findByModel(BaseErrlog baseErrlog)  {
        return baseErrlogMapper.findByModel(baseErrlog);
    }

    @Override
    public PaginationVO<BaseErrlog> findPageByModel(BaseErrlog baseErrlog, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum == null? 1 : pageNum, pageSize == null? 10 : pageSize);
        List<BaseErrlog> quesList = baseErrlogMapper.findByModelWithOrder(baseErrlog);
        PageInfo<BaseErrlog> pageInfo = new PageInfo<>(quesList);
        PaginationVO<BaseErrlog> paginationVo = new PaginationVO(pageInfo.getTotal(), pageInfo.getList());
        return paginationVo;
    }


}
